﻿using System;
using App_Code;


public partial class UserControls_UserLogin : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void Login_Click(object sender, EventArgs e)
    {
        //bool b;

        if (AuthClass.IsUserValid(txtUsername.Text, txtPassword.Text, true))
        {
            int userType = Convert.ToInt32(System.Web.HttpContext.Current.Session["UserTypeId"]);
            if (Request.QueryString["Path"] != null)
            {
                string RedirectUrl =
                    Request.Url.Query.ToLower().Replace("?path=", "").Replace("%2f", @"/").Replace("%3f", "?").Replace(
                        "%3d", "=").Replace("&20", "=");
                Response.Redirect(RedirectUrl);
            }
            else
            {
                Response.Redirect(Resources.PageURLs.HomePageURL);
            }

        }
        else
        {
            htmldivServerError.Visible = true;
            litError.Text = "User Id and password are wrong";

        }
    }
}
